<?php

namespace app\admin\model;

use app\common\model\BaseModel;


class Opus extends BaseModel
{

    

    

    // 表名
    protected $name = 'opus';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'channel_text'
    ];
    

    

    public function getChannelTextAttr($value, $data)
    {
        $value = $value ? $value : $data['channel'];
        $channel = array_flip(config('site.channel'));
        return isset($channel[$value]) ? $channel[$value] : '未知';
    }





    public function user()
    {
        return $this->belongsTo('User', 'user_id', 'id')->joinType('LEFT');
    }
}
